package day04;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;

public class ModeNumber {
    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileReader(new File("test.in")));
        } catch (FileNotFoundException e) {
            cin = new Scanner(System.in);
        }
    }

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = cin.nextInt();
        Arrays.sort(a);
        int[] dp = new int[n];
        dp[0] = 1;//a[0]在序列a[0:0]出现了一次
        for (int i = 1; i < n; i++) {
            if (a[i] != a[i - 1]) {
                dp[i] = 1;//a[i]在序列a[0:i]出现了一次
            } else {
                dp[i] = dp[i - 1] + 1;//a[i]在序列a[0:i]出现了dp[i-1]+1次
            }
        }
        System.out.println(Arrays.toString(dp));
        int key = 0, best = 1;
        for (int i = 1; i < n; i++) {
            if (dp[i] > best) {
                key = i;
                best = dp[i];
            }
        }
        System.out.println(a[key] + " " + best);
        cin.close();
    }


}